home *** CD-ROM | disk | FTP | other *** search
- ;==============================================================================
- ; Created by: Per Johansson aka Olle / Latex 2000
- ;
- ; Remember: Use at own risk. :) Compiled with: AsmPro V1.16d
- ;==============================================================================
- incdir Includes:
-
- include Exec/Exec_Lib.I
-
- include Dos/Dos_Lib.I
-
- include Intuition/Intuition_Lib.I
-
- include Graphics/Graphics_Lib.I
-
- include Libraries/Gadtools.I
- include Libraries/Gadtools_Lib.I
-
- include Libraries/Reqtools.I
- include Libraries/Reqtools_lib.i
-
- incdir .Asm:Tools/DiskLED/ ; Remember to change path.
- include SysInit.i
- ;==============================================================================
- ; DiskLED V1.2
- ;==============================================================================
- section DiskLED,code_p
-
- Start bsr OpenLibs
- tst.l d0
- bne .Nolibs
- bsr Read_Config
- bsr OpenWin0Window
- tst.l d0
- bne .NoWindow
- bsr.w Patch_Functions
- ;==================================================
- .MsgLoop CALLGRAF WaitTOF
- bsr.w Check_Floppy
- bsr.w Check_PowerLED
-
- move.l Win0,a1 ; Get win address
- move.l Wd_UserPort(a1),a2 ; Get message port
- move.l a2,a0
-
- CALLEXEC GetMsg ; Returns message in d0
- tst.l d0 ; See if message arrived
- beq .MsgLoop ; If no message then wait for next
-
- move.l d0,a1 ; Put intuimessage in a1
- move.l im_Class(a1),d2 ; Get class
- move.w im_Code(a1),d3 ; Get code
- move.l im_IAddress(a1),a4 ; Get IAddress
-
- cmp.l #IDCMP_REFRESHWINDOW,d2 ; Check Iconify-Gadget
- bne .Norefresh
- bsr Refresh_Window
- .Norefresh
- cmp.l #IDCMP_CLOSEWINDOW,d2 ; Quit if window closed
- bne .Noquit ; Remove when proper method implemented
- move.l #1,Done
- .Noquit cmp.l #IDCMP_MENUPICK,d2
- bne.w .Nomenupick
- move.l d3,d0 ; code into d0
- jsr ProcessMenuIDCMPNewMenu0
- .Nomenupick
- CALLEXEC ReplyMsg ; Return msg in A1
- cmp.l #1,done
- bne.w .MsgLoop ; Loop until End
- ;==================================================
- bsr.w DePatch_Functions
-
- move.l Win0,d0
- tst.l d0
- beq .NoWindow
- jsr CloseWin0Window
- .NoWindow jsr CloseLibs
- .NoLibs rts
-
-
- ;==============================================================================
- ; Functions for reading the config file.
- ;=============================================================\Read Config Init
- Read_Config
- move.l #ConfigFName,d1 ; File to open
- bsr _Dos_Openfile
-
- move.l #configBuffer,d2 ; Pointer to buffer
- move.l #1024,d3 ; Size to read
- bsr.w _Dos_Read
-
- move.l #'XPOS',d0
- bsr.w FindToken
- bsr.w Ascii2Dec
- move.w d0,XPos
-
- move.l #'YPOS',d0
- bsr.w FindToken
- bsr.w Ascii2Dec ; Store Decimal Value in (a1)
- move.w d0,YPos
-
- move.l #'PUB=',d0 ; Read Publicname
- bsr.w FindToken
- lea.l PublicName,a1
- move.l #256-1,d7
- .Copy cmp.b #'"',(a0)
- beq.w .Fin
- move.b (a0)+,(a1)+
- dbra d7,.Copy
- .Fin move.b #0,(a1)+
-
- moveq.l #0,d0
- moveq.l #0,d1
- move.w XPos(pc),d0
- move.w YPos(pc),d1
- move.w d0,Win0zoominfo
- move.w d1,Win0zoominfo+2
- ext.l d0
- ext.l d1
- move.l d0,Win0tags+4
- move.l d1,Win0tags+12
-
- .Fail bsr.w _Dos_Closefile
- rts
-
-
- ;========================================
- ; Ascii2Dec - Ascii to decimal converter
- ; IN: A0 = Ascii Source
- ; OUT: D0 = Decimal (.W)
- ;========================================
-
- Ascii2Dec moveq.l #0,d0
- move.b (a0),d0
- ext.w d0
- sub.w #$30,d0
- mulu #1000,d0
- moveq.l #0,d1
- move.b 1(a0),d1
- ext.w d1
- sub.w #$30,d1
- mulu #100,d1
- moveq.l #0,d2
- move.b 2(a0),d2
- ext.w d2
- sub.w #$30,d2
- mulu #10,d2
- moveq.l #0,d3
- move.b 3(a0),d3
- ext.w d2
- sub.w #$30,d3
- add.w d3,d2
- add.w d2,d1
- add.w d1,d0
- rts
-
- ;===================================
- ; IN: D0 = Token
- ; OUT: A0 = Ptr to token values
- ;===================================
-
- FindToken lea.l ConfigBuffer,a0
- move.l #1024-1,d7
- .Srch cmp.l (a0),d0
- beq .Fnd
- addq.l #1,a0
- dbra d7,.Srch
- .Fnd addq.l #5,a0
- rts
-
- ;==============================================================\Read Config End
-
- Check_Floppy
- cmp.w #2,StatusFlg
- beq.w .Nodf0
- move.l d0,-(Sp)
- moveq.l #0,d0
- move.b Ciabprb,d0
- btst #7,d0
- bne .No
- move.w #%00110011,B2t
- bra.w .Ok
- .No move.w #%00110111,B2t
- .Ok bsr.w Refresh_Window
- move.l (Sp)+,d0
- .Nodf0 rts
-
-
- Check_PowerLED
- move.l d0,-(Sp)
- moveq.l #0,d0
- move.b $bfe001,d0
- btst #1,d0
- beq .No
- move.w #%00110011,B3t
- bra.w .Ok
- .No move.w #%00110111,B3t
- .Ok bsr.w Refresh_Window
- move.l (Sp)+,d0
- rts
-
-
- Patch_Functions
- bsr.w Search_Floppys
- move.l #UnLoadsegroutine,d0
- move.l #_LVOUnLoadseg,a0
- bsr.w Setfunction
- move.l d0,Old_UnLoadsegadr
-
- move.l #Loadsegroutine,d0
- move.l #_LVOLoadseg,a0
- bsr.w Setfunction
- move.l d0,Old_Loadsegadr
-
- move.l #Openroutine,d0
- move.l #_LVOOpen,a0
- bsr.w Setfunction
- move.l d0,Old_Openadr
-
- move.l #Examineroutine,d0
- move.l #_LVOExamine,a0
- bsr.w Setfunction
- move.l d0,Old_Examineadr
-
- move.l #Exnextroutine,d0
- move.l #_LVOExnext,a0
- bsr.w Setfunction
- move.l d0,Old_Exnextadr
-
- move.l #Deleteroutine,d0
- move.l #_LVODeletefile,a0
- bsr.w Setfunction
- move.l d0,Old_Deleteadr
-
- move.l #Lockroutine,d0
- move.l #_LVOLock,a0
- bsr.w Setfunction
- move.l d0,Old_Lockadr
-
- move.l #DupLockroutine,d0
- move.l #_LVODupLock,a0
- bsr.w Setfunction
- move.l d0,Old_DupLockadr
-
- move.l #UnLockroutine,d0
- move.l #_LVOUnLock,a0
- bsr.w Setfunction
- move.l d0,Old_Unlockadr
-
- move.l #Openlibraryroutine,d0
- move.l #_LVOOpenlibrary,a0
- bsr.w Setfunction
- move.l d0,Old_Openlibadr
-
- move.l #Readroutine,d0
- move.l #_LVORead,a0
- bsr.w Setfunction
- move.l d0,Old_Readadr
-
- move.l #WriteRoutine,d0
- move.l #_LVOWrite,a0
- bsr.w Setfunction
- move.l d0,Old_Writeadr
-
- move.l #Closeroutine,d0
- move.l #_LVOClose,a0
- bsr.w Setfunction
- move.l d0,Old_Closeadr
-
- move.l #Closelibraryroutine,d0
- move.l #_LVOCloselibrary,a0
- bsr.w Setfunction
- move.l d0,Old_Closelibadr
- rts
-
- DePatch_Functions
- move.l Old_Unloadsegadr(pc),d0
- move.l #_LVOUnloadseg,a0
- bsr.w Setfunction
-
- move.l Old_Loadsegadr(pc),d0
- move.l #_LVOLoadseg,a0
- bsr.w Setfunction
-
- move.l Old_Openadr(pc),d0
- move.l #_LVOOpen,a0
- bsr.w Setfunction
-
- move.l Old_Readadr(pc),d0
- move.l #_LVORead,a0
- bsr.w Setfunction
-
- move.l Old_Writeadr(pc),d0
- move.l #_LVOWrite,a0
- bsr.w Setfunction
-
- move.l Old_Deleteadr(pc),d0
- move.l #_LVODeletefile,a0
- bsr.w Setfunction
-
- move.l Old_Lockadr(pc),d0
- move.l #_LVOLock,a0
- bsr.w Setfunction
-
- move.l Old_UnLockadr(pc),d0
- move.l #_LVOUnLock,a0
- bsr.w Setfunction
-
- move.l Old_Closeadr(pc),d0
- move.l #_LVOClose,a0
- bsr.w Setfunction
-
- move.l Old_Openlibadr(pc),d0
- move.l #_LVOOpenlibrary,a0
- bsr.w Setfunction
-
- move.l Old_Closelibadr(pc),d0
- move.l #_LVOCloselibrary,a0
- bsr.w Setfunction
-
- move.l Old_Duplockadr(pc),d0
- move.l #_LVODuplock,a0
- bsr.w Setfunction
-
- move.l Old_Examineadr(pc),d0
- move.l #_LVOExamine,a0
- bsr.w Setfunction
-
- move.l Old_Exnextadr(pc),d0
- move.l #_LVOExnext,a0
- bsr.w Setfunction
- rts
-
-
- ;==============================================================================
- ; Functions that shall Set the Led-option
- ;==============================================================================
- LoadsegRoutine
- move.l Old_Loadsegadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr Refresh_Window
- .No rts
-
- ExamineRoutine
- move.l Old_Examineadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr Refresh_Window
- .No rts
-
- ExnextRoutine
- move.l Old_Exnextadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- eor.w #%00000100,B1t
- bsr Refresh_Window
- .No rts
-
- LockRoutine
- move.l d1,Lockpath
- move.l Old_Lockadr(pc),a0
- jsr (a0)
- movem.l d0-d7/a0-a6,-(Sp)
- bsr.w Search_Floppys
- movem.l (Sp)+,d0-d7/a0-a6
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- DupLockRoutine
- move.l Old_DupLockadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- OpenRoutine
- move.l Old_Openadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- ReadRoutine
- move.l Old_Readadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- WriteRoutine
- move.l Old_Writeadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No Rts
-
- DeleteRoutine
- move.l Old_Deleteadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- OpenlibraryRoutine
- move.l Old_Openlibadr(pc),a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110011,B1t
- bsr.w Refresh_Window
- .No rts
-
- ;==============================================================================
- ; Functions that shall restore the Led-option
- ;==============================================================================
- UnLoadsegRoutine
- move.l Old_UnLoadsegadr,a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110111,B1t
- bsr.w Refresh_Window
- .No rts
-
- UnlockRoutine
- move.l Old_Unlockadr,a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110111,B1t
- bsr.w Refresh_Window
- .No rts
-
- CloseRoutine
- move.l Old_Closeadr,a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110111,B1t
- bsr.w Refresh_Window
- .No rts
-
- CloselibraryRoutine
- move.l Old_Closelibadr,a0
- jsr (a0)
- cmp.w #1,StatusFlg
- bge.w .No
- move.w #%00110111,B1t
- .no rts
-
- SetFunction
- move.l _Dosbase(pc),a1
- move.l _SysBase(pc),a6 ; Use The Multitasking Executive..:-)
- jsr _LVOSetFunction(a6) ; ----
- rts
-
- Search_Floppys
- move.l Lockpath(pc),a0
- lea.l .Tmp(pc),a1
- moveq.l #0,d0 ; Convert the first char to lowercase
- move.b (a0),d0
- bset #5,d0
- move.b d0,(a1)+
- moveq.l #0,d0 ; Convert the second char to lowercase
- move.b 1(a0),d0
- bset #5,d0
- move.b d0,(a1)+
- moveq.l #0,d0 ; Convert the third char to lowercase
- move.b 2(a0),d0
- bset #5,d0
- move.b d0,(a1)+
-
- cmp.l #'df0',.Tmp
- beq.w .Found1
-
- cmp.l #'df1',.Tmp
- beq.w .Found2
-
- cmp.l #'ram',.Tmp
- beq.w .Found2
-
- Move.w #0,StatusFlg
- Rts ; Not Found
- .Found1 Move.w #1,StatusFlg ; Tool shall only react on Df0: floppy
- Rts
- .Found2 Move.w #2,StatusFlg ; Ahh, Tool shall not react at all..
- Rts
- .Tmp Dc.l 0
-
- ;==============================================================================
- ; Show the about box.
- ;==============================================================================
- About_Diskled move.l _ReqtoolsBase(Pc),a6
- move.l #Main_Taglist,a0
- move.l #Main_Request,a1
- move.l #Main_Options,a2
- move.l #0,a3
- move.l _ReqtoolsBase(Pc),a6
- jsr _LvoRtEzRequesta(a6)
- rts
- ;==============================================================================
- even
- Main_Name dc.b " DiskLED V1.2 ",0
- even
- Main_Request dc.b ' DiskLED V1.2 ',10
- dc.b ' °°°°°°°°°°°° ',10
- dc.b ' Created and designed by: ',10
- dc.b ' Olle / Latex',10,10
- dc.b ' olle@ltx.nu or at www.ltx.nu',10
- dc.b ' Reqtools © Nico François ',0
- even
- Main_Options dc.b " _Okidoki",0
- even
- Main_Taglist dc.l Rt_Underscore,'_'
- dc.l RTEZ_ReqTitle,Main_Name
- dc.l RTEZ_Flags,EzReqf_Centertext
- dc.l RT_PubScrName,Win0scr
- dc.l 0
- even
- ;==============================================================================
- ; Variables & Constants
- ;==============================================================================
- CIABPRB = $BFD100
- XPos dc.w 0 ; Window Xpos
- YPos dc.w 0 ; Window Ypos
- Old_Examineadr dc.l 0
- Old_Exnextadr dc.l 0
- Old_Lockadr dc.l 0
- Old_Duplockadr dc.l 0
- Old_Unlockadr dc.l 0
- Old_Openadr dc.l 0
- Old_Readadr dc.l 0
- Old_Writeadr dc.l 0
- Old_Deleteadr dc.l 0
- Old_Openlibadr dc.l 0
- Old_Closeadr dc.l 0
- Old_Closelibadr dc.l 0
- Old_Loadsegadr dc.l 0
- Old_UnLoadsegadr dc.l 0
- Old_Exalladr dc.l 0
- Old_ExallEndadr dc.l 0
- Done dc.l 0 ; Set to 1 to quit
- Lockpath Dc.l 0
- StatusFlg Dc.w 0 ; Status for drives
- ConfigFName dc.b 'S:DLED.CFG',0
- even
- ;==============================================================================
-
-
- ;============================================
- ; Dos LinkObject
- ;============================================
- Xdef _Dos_Openfile ; D0=Ptr to filename
- Xdef _Dos_Closefile ; N/A
- Xdef _Dos_Read ; D2=DestPtr,D3=Length
- Xdef _Dos_Write ; D2=DestPtr,D3=Length
- Xdef _Dos_Delete ; D1=File to delete
- Xdef _Dos_Execute ; D1=File to execute
- Xdef _Dos_Delay ; D1=Time to wait (D1*50tps) (ticks per second)
- Xdef _Dos_Getsize ; D1=FileName,Ret:D0=Size
- Inclink Dos.lnk
- ;============================================
-
- include WinDesigner.i
-
- section bss,bss_p
-
- ConfigBuffer ds.b 1024
- PublicName ds.b 256
-